| 1 | --- |
| 2 | import type { GetStaticPathsResult } from "astro"; |
| 3 | import type { CollectionEntry } from "astro:content"; |
| 4 | import { getCollection } from "astro:content"; |
| 5 | import PostLayout from "@/layouts/BlogPost"; |
| 6 | |
| 7 | export async function getStaticPaths(): Promise<GetStaticPathsResult> { |
| 8 | const posts: CollectionEntry<"post">[] = await getCollection("post"); |
| 9 | const params = posts.map((post) => ({ |
| 10 | params: { post: post.slug }, |
| 11 | props: { post }, |
| 12 | })); |
| 13 | return params; |
| 14 | } |
| 15 | |
| 16 | interface Props { |
| 17 | post: CollectionEntry<"post">; |
| 18 | } |
| 19 | |
| 20 | const { post } = Astro.props; |
| 21 | const { Content } = await post.render(); |
| 22 | --- |
| 23 | |
| 24 | <PostLayout post={post}> |
| 25 | <Content /> |
| 26 | </PostLayout> |